﻿module nGo.Web.Mvc.Tests

open System
open System.Data.Entity
open System.Data.Entity.Infrastructure
open System.Web.Http
open System.Web.Mvc
open System.Web.Optimization
open System.Web.Routing

open nGo.Web.Mvc

type TestApp() =
    inherit Application()

    let mutable areasRegistered = false
    let mutable dbRegistered = false
    let mutable filtersRegistered = false
    let mutable routesRegistered = false
    let mutable bundlesRegistered = false

    override x.RegisterAreas() = areasRegistered <- true; areasRegistered
    override x.SetDefaultDb(defaultDbConnectionFactory) = dbRegistered <- true; defaultDbConnectionFactory
    override x.AddFilters(filters) = filtersRegistered <- true; filters
    override x.AddRoutes(routes) = routesRegistered <- true; routes
    override x.AddBundles(bundles) = bundlesRegistered <- true; bundles

    member x.EverythingCalled with get() = areasRegistered && dbRegistered && filtersRegistered && routesRegistered && bundlesRegistered

[<Test.Case>]
let testAppStart () =
    let app = new TestApp()
    Test.no "app not started" app.IsStarted
    app.Init()
    Test.yes "app started" app.IsStarted
    Test.yes "all calls" app.EverythingCalled

